package com.wjy.icu.websocket.controller;



import com.wjy.icu.common.core.domain.R;
import com.wjy.icu.websocket.server.WebSocketServer;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

/**
 * @Description:
 * @author: wangjunyong
 * @date: 2020/12/28 18:12
 */
@Controller
@RequestMapping("/checkcenter")
public class SocketController {


    //推送数据接口
    @ResponseBody
    @RequestMapping(value = "/socket/push/{cid}",method = RequestMethod.POST)
    public R pushToWeb(@PathVariable String cid, @RequestBody String message) {
        try {
            WebSocketServer.sendInfo(message,cid);
        } catch (IOException e) {
            e.printStackTrace();
            return R.error(cid+"#"+e.getMessage());
        }
        return R.ok(cid);
    }
}
